package com.snda.storage.service.sdk;

import static com.google.common.base.Preconditions.checkNotNull;

import javax.annotation.concurrent.Immutable;

import org.joda.time.DateTime;

/**
 * 
 * @author wangzijian
 * 
 */
@Immutable
public final class ObjectSummary extends ValueObject {

	private final String key;
	private final long size;
	private final String entityTag;
	private final DateTime lastModified;

	private ObjectSummary(Builder builder) {
		this.key = checkNotNull(builder.key, "key");
		this.size = checkNotNull(builder.size, "size");
		this.entityTag = checkNotNull(builder.entityTag, "entityTag");
		this.lastModified = checkNotNull(builder.lastModified, "lastModified");
	}
	
	public String getKey() {
		return key;
	}

	public long getSize() {
		return size;
	}

	public String getEntityTag() {
		return entityTag;
	}

	public DateTime getLastModified() {
		return lastModified;
	}

	public static final class Builder {
		private String key;
		private Long size;
		private String entityTag;
		private DateTime lastModified;

		public ObjectSummary build() {
			return new ObjectSummary(this);
		}

		public Builder key(String key) {
			this.key = key;
			return this;
		}

		public Builder size(Long size) {
			this.size = size;
			return this;
		}

		public Builder entityTag(String entityTag) {
			this.entityTag = entityTag;
			return this;
		}

		public Builder lastModified(DateTime lastModified) {
			this.lastModified = lastModified;
			return this;
		}
	}
}
